import "../css/DataCleaner-JMiI7bKQ.css";
import { defineComponent as ue, toRefs as se, ref as p, reactive as H, onMounted as re, openBlock as O, createElementBlock as J, createTextVNode as C, createVNode as s, unref as u, withCtx as i, createElementVNode as M, toDisplayString as ie, Fragment as de, renderList as pe, createBlock as ce, nextTick as T } from "vue";
import { aZ as X, b as w, r as fe, e as E, H as Y, B as Z, C as c, aX as me, aY as F, j as be, k as ve, f as z, g as ge } from "./vendor.CF2kwqqq.js";
import { d as G, b as he, e as Ve } from "./index.Bbfhrq76.js";
import { _ as De } from "./_plugin-vue_export-helper.CHgC5LLL.js";
const _e = ["int", "long", "short", "float", "double"], P = [
  {
    label: "将空值替换为指定值",
    value: "将空值替换为指定值",
    disabled: [!1, !0]
  },
  { label: "过滤整行空值", value: "过滤整行空值", disabled: [!0, !0] },
  { label: "移除所有空格", value: "移除所有空格", disabled: [!0, !0] },
  { label: "移除首尾空格", value: "移除首尾空格", disabled: [!0, !0] },
  { label: "移除标点符号", value: "移除标点符号", disabled: [!0, !0] },
  { label: "移除数字", value: "移除数字", disabled: [!0, !0] },
  { label: "移除字母", value: "移除字母", disabled: [!0, !0] },
  { label: "设为小写", value: "设为小写", disabled: [!0, !0] },
  { label: "设为大写", value: "设为大写", disabled: [!0, !0] },
  { label: "首字母大写", value: "首字母大写", disabled: [!0, !0] },
  { label: "值替换", value: "值替换", disabled: [!1, !1] },
  { label: "字符串替换", value: "字符串替换", disabled: [!1, !1] },
  { label: "正则替换", value: "正则替换", disabled: [!1, !1] }
], ye = [
  {
    label: "将空值替换为指定值",
    value: "将空值替换为指定值",
    disabled: [!1, !0]
  },
  { label: "过滤整行空值", value: "过滤整行空值", disabled: [!0, !0] },
  { label: "值替换", value: "值替换", disabled: [!1, !1] }
], Q = (d) => d && _e.includes(d.toLowerCase()) ? ye : P, k = (d, g) => Q(d).find((I) => I.value === g), xe = { class: "nifi-cleaning" }, Ce = { class: "cleaning_content" }, Me = { "w-30vw": "" }, ke = { "w-40vw": "" }, Ie = { style: { "margin-bottom": "18px" } }, Se = { class: "allocation_footer" }, we = /* @__PURE__ */ ue({
  __name: "index",
  props: {
    formdata: {},
    propInput: {},
    propOutput: {},
    inputV: {}
  },
  setup(d) {
    const g = d, { formdata: h, inputV: V, propOutput: I, propInput: L } = se(g), D = p(!1), _ = () => {
      if (D.value = !0, x.value = !1, j(), b.value.length === 0 || t.cleaningData.length === 0) {
        x.value = !0;
        return;
      }
      b.value.length === t.cleaningData.length ? T(() => {
        var l;
        (l = f.value) == null || l.toggleAllSelection(), x.value = !0;
      }) : T(() => {
        t.cleaningData.forEach((l) => {
          var a, e;
          let n = (a = b.value) == null ? void 0 : a.find((o) => o.name === l.name);
          n && ((e = f.value) == null || e.toggleRowSelection(n, !0));
        }), x.value = !0;
      });
    }, f = p(), b = p(V.value), B = p([]), t = H({
      tableData: [],
      // 表格真正的数据
      cleaningData: []
      // 展示的数据--可搜索
    }), W = (l) => {
      if (x.value) {
        if (B.value = l, l.length < t.tableData.length) {
          if (l.length === 0) {
            t.cleaningData = [], t.tableData = [];
            return;
          }
          let n = t.tableData.filter(
            (a) => l.every((e) => a.name != e.name)
          );
          for (let a = 0; a < n.length; a++)
            for (let e = 0; e < t.tableData.length; e++)
              if (t.tableData[e].name === n[a].name) {
                t.tableData.splice(e, 1);
                let o = t.cleaningData.findIndex(
                  (r) => r.name === n[a].name
                );
                o > -1 && t.cleaningData.splice(o, 1), e--;
              }
        } else if (l.length > t.tableData.length) {
          let n = l.filter(
            (e) => t.cleaningData.every((o) => e.name !== o.name)
          ), a = l.filter(
            (e) => t.tableData.every((o) => e.name !== o.name)
          );
          v.value === "" && t.cleaningData.push(...n), t.tableData.push(...a), N();
        }
      }
    }, $ = () => {
      b.value = [], B.value = [], t.tableData = [], t.cleaningData = [], y.value = "", v.value = "";
    }, R = () => {
      D.value = !1, $();
    }, ee = (l) => {
      var o;
      let n = t.cleaningData.findIndex((r) => r.name === l.name);
      t.cleaningData.splice(n, 1);
      let a = t.tableData.findIndex((r) => r.name === l.name);
      t.tableData.splice(a, 1);
      let e = B.value.find((r) => r.name === l.name);
      (o = f.value) == null || o.toggleRowSelection(e, !1);
    }, S = p(), U = H({
      testMethod: [
        { required: !0, message: "检测方法不能为空", trigger: "change" }
      ],
      sValue: [{ required: !0, message: "指定值不能为空", trigger: "blur" }]
    }), ae = async () => {
      var l;
      await ((l = S.value) == null ? void 0 : l.validate((n, a) => {
        n ? (K(), R()) : console.log("error submit!", a);
      }));
    }, y = p(""), v = p(""), le = X(() => {
      let l = y.value.toLowerCase();
      b.value = q.value.filter(
        (n) => n.name.toLowerCase().includes(l)
      );
    }, 500), N = X(() => {
      let l = v.value.toLowerCase();
      t.cleaningData = t.tableData.filter(
        (n) => n.name.toLowerCase().includes(l)
      );
    }, 300), te = (l, n) => {
      var o;
      let { testMethod: a, type: e } = n;
      if (a && ((o = k(e, a)) != null && o.disabled[0])) {
        let r = `cleaningData.${l}.sValue`;
        return T(() => {
          var m, A;
          (m = S.value) == null || m.clearValidate(r), (A = S.value) == null || A.validateField(r, async (oe) => await oe);
        }), [];
      }
      return [{ required: !0, message: "指定值不能为空", trigger: "blur" }];
    }, ne = (l, n) => {
      var o, r;
      let { testMethod: a, type: e } = n;
      a && ((o = k(e, a)) != null && o.disabled[0]) && (t.cleaningData[l].sValue = "", t.tableData[l].sValue = ""), a && ((r = k(e, a)) != null && r.disabled[1]) && (t.cleaningData[l].oValue = "", t.tableData[l].oValue = "");
    }, q = p(V.value), x = p(!1), K = () => {
      let l = q.value.map(
        ({ name: n, doc: a, type: e, originalValue: o }) => ({
          name: n,
          doc: a,
          type: e,
          originalValue: o
        })
      );
      z(h.value, I.value, G(l)), z(h.value, L.value, G(t.tableData));
    }, j = () => {
      b.value = V.value;
      let l = ge(h.value, L.value);
      if (l) {
        let n = JSON.parse(l), a = [];
        n.forEach((e) => {
          let o = {
            doc: e.doc,
            name: e.name,
            type: e.type,
            sValue: e.sValue ?? "",
            oValue: e.oValue ?? "",
            testMethod: e.testMethod
          };
          a.push(o);
        }), a.length !== t.cleaningData.length && (t.cleaningData = [...a], t.tableData = [...a]);
      }
    };
    return re(() => {
      j(), K();
    }), (l, n) => (O(), J("div", xe, [
      C(" 数据清洗配置: "),
      s(u(w), {
        type: "primary",
        onClick: _,
        style: { "margin-left": "12px" }
      }, {
        default: i(() => [
          C(" 数据清洗配置 ")
        ]),
        _: 1
      }),
      s(u(fe), {
        modelValue: D.value,
        "onUpdate:modelValue": n[4] || (n[4] = (a) => D.value = a),
        title: "数据清洗配置",
        "destroy-on-close": "",
        "h-70vh": "",
        "before-close": R
      }, {
        default: i(() => [
          M("div", Ce, [
            M("div", Me, [
              s(u(E), {
                modelValue: y.value,
                "onUpdate:modelValue": n[0] || (n[0] = (a) => y.value = a),
                placeholder: "请输入",
                "prefix-icon": u(Y),
                onInput: u(le),
                onBlur: n[1] || (n[1] = (a) => {
                  var e;
                  return y.value = (e = a.target) == null ? void 0 : e.value.trim();
                })
              }, null, 8, ["modelValue", "prefix-icon", "onInput"]),
              s(u(Z), {
                ref_key: "multipleTableRef",
                ref: f,
                "max-height": "400",
                data: b.value,
                "cell-style": { "text-align": "center" },
                "header-cell-style": { "text-align": "center" },
                "row-key": "name",
                onSelectionChange: W,
                "m-t-12": ""
              }, {
                default: i(() => [
                  s(u(c), {
                    type: "selection",
                    width: "55",
                    "reserve-selection": ""
                  }),
                  s(u(c), {
                    prop: "name",
                    label: "字段名",
                    "show-overflow-tooltip": ""
                  }),
                  s(u(c), {
                    prop: "doc",
                    label: "字段中文名",
                    "show-overflow-tooltip": ""
                  }),
                  s(u(c), {
                    prop: "type",
                    label: "字段类型",
                    "show-overflow-tooltip": ""
                  })
                ]),
                _: 1
              }, 8, ["data"])
            ]),
            M("div", ke, [
              s(u(E), {
                modelValue: v.value,
                "onUpdate:modelValue": n[2] || (n[2] = (a) => v.value = a),
                placeholder: "请输入",
                "prefix-icon": u(Y),
                onInput: u(N),
                onBlur: n[3] || (n[3] = (a) => {
                  var e;
                  return v.value = (e = a.target) == null ? void 0 : e.value.trim();
                })
              }, null, 8, ["modelValue", "prefix-icon", "onInput"]),
              s(u(me), {
                ref_key: "formRef",
                ref: S,
                model: t,
                rules: U,
                "m-t-12": ""
              }, {
                default: i(() => [
                  s(u(Z), {
                    data: t.cleaningData,
                    "max-height": "400",
                    "cell-style": { textAlign: "center" },
                    "header-cell-style": { "text-align": "center" }
                  }, {
                    default: i(() => [
                      s(u(c), {
                        label: "字段名",
                        "show-overflow-tooltip": ""
                      }, {
                        default: i(({ row: a }) => [
                          M("div", Ie, ie(a.name), 1)
                        ]),
                        _: 1
                      }),
                      s(u(c), {
                        label: "检测方法",
                        width: "150px"
                      }, {
                        default: i(({ $index: a, row: e }) => [
                          s(u(F), {
                            prop: "cleaningData." + a + ".testMethod",
                            rules: U.testMethod
                          }, {
                            default: i(() => [
                              s(u(be), {
                                modelValue: e.testMethod,
                                "onUpdate:modelValue": (o) => e.testMethod = o,
                                placeholder: "请选择",
                                class: "item__input",
                                "popper-class": "select_popper",
                                onChange: (o) => ne(a, e)
                              }, {
                                default: i(() => [
                                  (O(!0), J(de, null, pe(u(Q)(e.type), (o) => (O(), ce(u(ve), {
                                    label: o.label,
                                    value: o.value,
                                    key: o.value
                                  }, null, 8, ["label", "value"]))), 128))
                                ]),
                                _: 2
                              }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"])
                            ]),
                            _: 2
                          }, 1032, ["prop", "rules"])
                        ]),
                        _: 1
                      }),
                      s(u(c), {
                        label: "指定值",
                        width: "150px"
                      }, {
                        default: i(({ $index: a, row: e }) => [
                          s(u(F), {
                            prop: "cleaningData." + a + ".sValue",
                            rules: te(a, e)
                          }, {
                            default: i(() => {
                              var o;
                              return [
                                s(u(E), {
                                  modelValue: e.sValue,
                                  "onUpdate:modelValue": (r) => e.sValue = r,
                                  placeholder: "请输入",
                                  disabled: (o = u(k)(e.type, e.testMethod)) == null ? void 0 : o.disabled[0],
                                  class: "item__input",
                                  clearable: "",
                                  onBlur: (r) => {
                                    var m;
                                    return e.sValue = (m = r.target) == null ? void 0 : m.value.trim();
                                  }
                                }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "onBlur"])
                              ];
                            }),
                            _: 2
                          }, 1032, ["prop", "rules"])
                        ]),
                        _: 1
                      }),
                      s(u(c), {
                        label: "原值",
                        width: "150px"
                      }, {
                        default: i(({ $index: a, row: e }) => [
                          s(u(F), {
                            prop: "cleaningData." + a + ".oValue",
                            rules: U.oValue
                          }, {
                            default: i(() => {
                              var o;
                              return [
                                s(u(E), {
                                  modelValue: e.oValue,
                                  "onUpdate:modelValue": (r) => e.oValue = r,
                                  placeholder: "请输入",
                                  disabled: (o = u(k)(e.type, e.testMethod)) == null ? void 0 : o.disabled[1],
                                  class: "item__input",
                                  clearable: "",
                                  onBlur: (r) => {
                                    var m;
                                    return e.oValue = (m = r.target) == null ? void 0 : m.value.trim();
                                  }
                                }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "onBlur"])
                              ];
                            }),
                            _: 2
                          }, 1032, ["prop", "rules"])
                        ]),
                        _: 1
                      }),
                      s(u(c), { label: "操作" }, {
                        default: i(({ row: a }) => [
                          s(u(w), {
                            text: "",
                            onClick: () => ee(a),
                            style: { "margin-bottom": "18px" }
                          }, {
                            default: i(() => [
                              C(" 删除 ")
                            ]),
                            _: 2
                          }, 1032, ["onClick"])
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }, 8, ["data"])
                ]),
                _: 1
              }, 8, ["model", "rules"])
            ])
          ]),
          M("div", Se, [
            s(u(w), { onClick: R }, {
              default: i(() => [
                C("取消")
              ]),
              _: 1
            }),
            s(u(w), {
              type: "primary",
              onClick: ae
            }, {
              default: i(() => [
                C("保存")
              ]),
              _: 1
            })
          ])
        ]),
        _: 1
      }, 8, ["modelValue"])
    ]));
  }
}), Ee = /* @__PURE__ */ De(we, [["__scopeId", "data-v-cb0a4bcf"]]), Te = () => {
  let d = [];
  const g = ["output-param", "output字段（自动填入）"];
  return { name: ["org.apache.nifi.column.processors.DataCleaner_1_0"], excludeKeys: ["expression", "output-param"], selfFormColumn: [
    {
      tag: Ee,
      propInput: "config.properties['expression']",
      propOutput: "config.properties['output-param']",
      ":formdata": "formData",
      setup() {
        return { inputV: d };
      },
      ":inputV": "inputV"
    }
  ], hooksOpen: (_, f) => {
    d = [], d = he(_, f, g);
  }, hooksSubmit: (_, f) => {
    Ve(_, f);
  } };
};
export {
  Te as default
};
